Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install using the setuptools.build_meta backend #1535

Merged
merged 2 commits into from
May 13, 2023

Conversation

csris
Copy link
Contributor

@csris csris commented May 6, 2023

Installing with pip install -e . fails due to setup.py being deprecated after setuptools adopted PEP-517 [1]. Migrate to building using a setup.cfg file.

This was mostly a 1-to-1 migration except for setting install_requires. Setuptools recommends not reading requirements.txt as the value for install_requires [4].

See also:

  • A Practical Guide to Setuptools and Pyproject.toml [2]
  • Configuring setuptools using setup.cfg files [3]

[1] https://peps.python.org/pep-0517/
[2] https://godatadriven.com/blog/a-practical-guide-to-setuptools-and-pyproject-toml/
[3] https://setuptools.pypa.io/en/latest/userguide/declarative_config.html
[4] pypa/setuptools#1951

Installing with `pip install -e .` fails due to setup.py being
deprecated after setuptools adopted PEP-517 [1]. Migrate to building
using a setup.cfg file.

This was mostly a 1-to-1 migration except for setting
`install_requires`. Setuptools recommends not reading `requirements.txt`
as the value for `install_requires` [4].

See also:
- A Practical Guide to Setuptools and Pyproject.toml [2]
- Configuring setuptools using setup.cfg files [3]

[1] https://peps.python.org/pep-0517/
[2] https://godatadriven.com/blog/a-practical-guide-to-setuptools-and-pyproject-toml/
[3] https://setuptools.pypa.io/en/latest/userguide/declarative_config.html
[4] pypa/setuptools#1951
@csris
Copy link
Contributor Author

csris commented May 6, 2023

When following the HELM quick start, I was running into this error while installing.

/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.   
  warnings.warn(                                                                                                                                                               
Traceback (most recent call last):                                                                                                                                             
  File "<string>", line 2, in <module>                                                                                                                                         
  File "<pip-setuptools-caller>", line 34, in <module>                                                                                                                         
  File "/private/var/folders/kc/j96fg3t17cj8pfh5plg43jf80000gn/T/pip-install-weheancd/pyemd_5e7564fe5f5649f4a1a4764a7d792b19/setup.py", line 99, in <module>
    setup(                                                                                                                                                                     
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/__init__.py", line 86, in setup
    _install_setup_requires(attrs)                                                                                                                                             
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/__init__.py", line 80, in _install_setup_requires
    dist.fetch_build_eggs(dist.setup_requires)                                                                                                                                 
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/dist.py", line 874, in fetch_build_eggs
    resolved_dists = pkg_resources.working_set.resolve(                                                                                                                        
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/pkg_resources/__init__.py", line 815, in resolve
    dist = self._resolve_dist(                                                                                                                                                 
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/pkg_resources/__init__.py", line 851, in _resolve_dist
    dist = best[req.key] = env.best_match(                                                                                                                                     
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1123, in best_match
    return self.obtain(req, installer)                                                                                                                                         
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/pkg_resources/__init__.py", line 1135, in obtain
    return installer(requirement)                                                                                                                                              
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/dist.py", line 944, in fetch_build_egg
    return fetch_build_egg(self, req)                                                                                                                                          
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/installer.py", line 87, in fetch_build_egg
    wheel.install_as_egg(dist_location)                                                                                                                                        
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/wheel.py", line 110, in install_as_egg
    self._install_as_egg(destination_eggdir, zf)                                                                                                                               
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/wheel.py", line 118, in _install_as_egg
    self._convert_metadata(zf, destination_eggdir, dist_info, egg_info)                                                                                                        
  File "/Users/csris/miniconda3/envs/crfm-helm/lib/python3.8/site-packages/setuptools/wheel.py", line 162, in _convert_metadata
    os.rename(dist_info, egg_info)                                                                                                                                             

Steps to Reproduce

  1. conda create -n crfm-helm python=3.8 pip
  2. conda activate crfm-helm
  3. From within my checkout's working directory: pip install -e .

@percyliang percyliang requested a review from yifanmai May 7, 2023 03:48
@csris
Copy link
Contributor Author

csris commented May 7, 2023

On second thought, we should probably leave the setup.py in the repo for legacy clients. I believe new versions of pip use the pyproject.toml if it exists, and older versions that don't support the new style will use the setup.py. @yifanmai, let me know what you think.

Copy link
Collaborator

@yifanmai yifanmai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks!

I think we can remove setup.py (I don't think we need build system reverse compatibility).

setup.cfg Outdated Show resolved Hide resolved
@yifanmai yifanmai merged commit 88f987b into stanford-crfm:main May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants